package com.cloudpivot.receivales.ding.robot.controller;

import com.alibaba.fastjson.JSONObject;
import com.cloudpivot.receivales.ding.robot.service.baidu.BaiduNPLServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Objects;

@Controller
@Slf4j
@RequestMapping("/baiduService/")
public class BaiduNPLController {

    @Autowired
    private BaiduNPLServiceImpl baiduService;

    @ResponseBody
    @PostMapping("/embSim")
    public JSONObject embSimController(@RequestBody JSONObject entity) {
        if (Objects.isNull(entity)) {
            return null;
        }
        String one = entity.getString("one");
        String two = entity.getString("two");
        JSONObject jsonObject = baiduService.embSimService(one, two);
        return jsonObject;
    }
}
